extends archetypes/content-with-menu.pug

include mixins/nav.pug

include mixins/documentationjs/description.pug
include mixins/documentationjs/type.pug
include mixins/documentationjs/struct.pug
include mixins/documentationjs/widget-usage.pug

block navigation
  - let headings = [{tag: 'h2', id: 'description', text: 'Description'}]
  - if(jsdoc.requirements != '') headings.push({tag: 'h2', id:'requirements', text:'Requirements'})
  - headings.push({tag: 'h2', id:'live', text:'Live example'});
  - headings.push({tag: 'h2', id:'usage', text:'Usage'}, {tag:'h2', id:'structure', text: 'Options'});
  - if(jsdoc.examples && jsdoc.examples.length > 0) headings.push({tag:'h2', id:'example', text: 'Example'});
  - if(jsdoc.staticExamples && jsdoc.staticExamples.length > 0) headings.push({tag:'h2', id:'example', text: 'Example'});
  +nav(navPath, navigation, mainTitle || title, withHeadings && headings || [])

block content
  h2#description Description
    a.anchor(href=`${navPath}#description`)
  p
    +description(jsdoc.description)

  if jsdoc.requirements
    h2#requirements Requirements
      a.anchor(href=`${navPath}#requirements`)
    p
      +description(jsdoc.requirements)

  h2#live Live example
    a.anchor(href=`${navPath}#live`)
  p
    if (jsdoc.devNovel)
      | You can find an example #[a(href=`${navPath}#example`) at the end of the page] or a live example in #[a(href=`${publicPath}${jsdoc.devNovel}` target="_blank" rel="noopener") our widget showcase].
    else
      | You can find an example #[a(href=`${navPath}#example`) at the end of the page].

  h2#usage Usage
    a.anchor(href=`${navPath}#usage`)
  +widgetUsage(jsdoc)

  if jsdoc.params && jsdoc.params.length === 1 && jsdoc.params[0].name === '$0'
    if jsdoc.relatedTypes && jsdoc.relatedTypes.length > 0
      h2#structure Options
        a.anchor(href=`${navPath}#structure`)
      each t in jsdoc.relatedTypes
        if t
          +struct(t, jsdoc.relatedTypes)
  else if jsdoc.params
    h2#structure Options
      a.anchor(href=`${navPath}#structure`)
    ul.struct-def
      each property in jsdoc.params
        li.type(id=`struct-${property.name}`)
          strong=property.name
          a.anchor(href=`${navPath}#param-${property.name}`)
          code
            +type(property.type, jsdoc.relatedTypes)
          if tag && tag.default
            div.default-value
              | Default value:
              code=tag.default
          +description(property.description)

  if jsdoc.examples && jsdoc.examples.length > 0
    h2#example Example
      a.anchor(href=`${navPath}#example`)
    each example in jsdoc.examples
      div!=h.highlight(example.description)

  if jsdoc.staticExamples && jsdoc.staticExamples.length > 0
      h2#example Example
        a.anchor(href=`${navPath}#example`)
      each example in jsdoc.staticExamples
        div!=h.highlight(example.description, { runnable: false })
